﻿@model IEnumerable<MatchSummaryViewModel>

@if (Model == null)
{
    <p>No records found</p>
}
else
{
    @(Html.Kendo().Grid(Model)
        .Name("matchSearchResultsGrid")
        .Columns(columns =>
        {
            columns.Bound(item => item.MatchDate);
            columns.Bound(item => item.CompetitionName);
            columns.Bound(item => item.VenueName);
            columns.Bound(item => item.Team1Name);
            columns.Bound(item => item.FullTimeScore);
            columns.Bound(item => item.Team2Name);
            columns.Template(@<text>
                  @if (item.IsApproved)
                  {
                      <img src="~/Content/images/tick.png" height="18" />
                  }
                  else 
                  {
                      <img src="~/Content/images/cross.png" height="18" />
                  }
                  </text>).Title("Approved");
            columns.Template(@<text>
                <span>@Html.ActionLink("Edit", "Index", "Edit", new { id = item.MatchGuid }, null)</span>

                @if(item.CanDelete)
                {
                <span>@Html.ActionLink("Delete", "Delete", "Edit", new { id = item.MatchGuid }, new { onclick = "return confirm('Are you sure?');" })</span>
                }

                @if(item.CanApprove)
                {
                <span>@Html.ActionLink("View approvals", "Approve", "Edit", new { id = item.MatchGuid}, null)</span>
                }

            </text>).Title("Action");

          })
          .Sortable() 
          .DataSource(dataSource => dataSource
              .Server()
              .Model(model => model.Id(product => product.MatchGuid))
          )
    )
}
